package com.chia.multienty.core.controller;


import com.chia.multienty.core.domain.condition.MasterOrUserCondition;
import org.springframework.context.annotation.Conditional;
import org.springframework.web.bind.annotation.RequestMapping;
import com.chia.multienty.core.service.AppVersionService;
import com.chia.multienty.core.domain.dto.AppVersionDTO;
import com.chia.multienty.core.pojo.AppVersion;
import com.chia.multienty.core.parameter.base.AppVersionDetailGetParameter;
import com.chia.multienty.core.parameter.base.AppVersionPageGetParameter;
import com.chia.multienty.core.parameter.base.AppVersionDeleteParameter;
import com.chia.multienty.core.parameter.base.AppVersionSaveParameter;
import com.chia.multienty.core.parameter.base.AppVersionUpdateParameter;
import com.chia.multienty.core.parameter.base.AppVersionEnableParameter;
import com.chia.multienty.core.parameter.base.AppVersionDisableParameter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.chia.multienty.core.annotation.WebLog;
import com.chia.multienty.core.domain.basic.Result;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
 * <p>
 * 应用版本 服务
 * </p>
 *
 * @author Multi Tenant Auto Generator
 * @since 2024-07-19
 */
@RestController
@Validated
@RequestMapping("/app-version")
@RequiredArgsConstructor
@Api(tags = "应用版本")
@Conditional(MasterOrUserCondition.class)
public class AppVersionController {

    private final AppVersionService appVersionService;

    @PostMapping("/detail")
    @ApiOperation("获取应用版本详情")
    public Result<AppVersionDTO> getDetail(@Validated @RequestBody AppVersionDetailGetParameter parameter) {
        AppVersionDTO detail = appVersionService.getDetail(parameter);
        return new Result<>(detail);
    }

    @PostMapping("/page")
    @ApiOperation("获取应用版本分页列表")
    public Result<IPage<AppVersionDTO>> getPage(@Validated @RequestBody AppVersionPageGetParameter parameter) {
        IPage<AppVersionDTO> page = appVersionService.getPage(parameter);
        return new Result<>(page);
    }

    @PostMapping("/update")
    @ApiOperation("更新应用版本")
    @WebLog(target = "AppVersion")
    public Result<Boolean> update(@Validated @RequestBody AppVersionUpdateParameter parameter) {
        appVersionService.update(parameter);
        return new Result<>(true);
    }

    @PostMapping("/save")
    @ApiOperation("保存应用版本")
    @WebLog(target = "AppVersion")
    public Result<Boolean> save(@Validated @RequestBody AppVersionSaveParameter parameter) {
        appVersionService.save(parameter);
        return new Result<>(true);
    }

    @PostMapping("/enable")
    @ApiOperation("启用应用版本")
    @WebLog(target = "AppVersion")
    public Result<Boolean> enable(@Validated @RequestBody AppVersionEnableParameter parameter) {
        appVersionService.enable(parameter);
        return new Result<>(true);
    }

    @PostMapping("/disable")
    @ApiOperation("禁用应用版本")
    @WebLog(target = "AppVersion")
    public Result<Boolean> disable(@Validated @RequestBody AppVersionDisableParameter parameter) {
        appVersionService.disable(parameter);
        return new Result<>(true);
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除应用版本")
    @WebLog(target = "AppVersion")
    public Result<Boolean> delete(@Validated @RequestBody AppVersionDeleteParameter parameter) {
        appVersionService.delete(parameter);
        return new Result<>(true);
    }

}
